﻿using System.Collections.Generic;
using System.Runtime.Serialization;
using Rodunu.Business.Models.Movies;

namespace Rodunu.Business.Models.User
{
    [DataContract]
    [KnownType(typeof(Account))]
    public class User
    {
        [DataMember]
        public string UserName { get; set; }

        [DataMember]
        public string Password { get; set; }

        [DataMember]
        public string FirstName { get; set; }

        [DataMember]
        public string LastName { get; set; }

        private IList<Account> _accounts;

        [DataMember]
        public IList<Account> Accounts
        {
            get
            {
                if (_accounts != null)
                {
                    IList<Account> accounts = new List<Account>();
                    foreach (var account in _accounts)
                    {
                        accounts.Add(account);
                    }
                    _accounts = accounts;
                    return _accounts;
                }
                _accounts = new List<Account>();
                return _accounts;
            }
            set
            {
                _accounts = value;
            }
        }

        [DataMember]
        public IList<Title> Collection { get; set; }
    }
}
